// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "HotChunkFile.generated.h"


struct FVersionWebInfo
{
	TArray<FString> WebSites;
	TArray<FString> ResSites;
	FString CloudDir;
	FString ManifestDir;
	FString VersionFile;
};

struct FChunkManifestInfo
{
	FString Filename;
	FString UniqueFilename;
	FString Length;
	FString URL;
	FString Hash;
	FString Hash256;
	FString ChunkName;

	FChunkManifestInfo(FString InFilename, FString InUniqueFilename, FString InLength, FString InURL, FString InHash, FString InHash256, FString InChunkName) : Filename(InFilename), UniqueFilename(InUniqueFilename), Length(InLength), URL(InURL), Hash(InHash), Hash256(InHash256), ChunkName(InChunkName) {}
};

struct FVersionManifestInfo
{
	FString ClientVersion;
	FString BuildUrl;
	FString Platform;
	TMap<FString, TSharedPtr<FChunkManifestInfo>> ChunkManifestInfos;
	//TArray<TSharedPtr<FChunkManifestInfo>> ChunkManifestInfos;
	FVersionManifestInfo(FString InClientVersion, FString InBuildUrl) : ClientVersion(InClientVersion), BuildUrl(InBuildUrl) {
		BuildUrl.Split(FString("/"), NULL, &Platform);
	}
};


/**
 *
 */
UCLASS()
class HOTCHUNK_API UHotChunkFile : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:

	static TSharedPtr<FVersionWebInfo> ConvertJsonToVersionVersionWebInfo(FString JsonContent);

	static TSharedPtr<FVersionManifestInfo> ConvertJsonToVersionManifestInfo(FString JsonContent);

	static FString ConvertVersionManifestInfoToJson(TSharedPtr<FVersionManifestInfo> VersionManifestInfo);

	static float GetDiskFreeSpace();

};
